#include <amxmodx>
#include <engine>
#include <rpgx>
#include <xs>

new upgrade_id;

public plugin_init()
	register_plugin("BouncyBullets RPGx Upgrade", "2.1", "roflmao456");

public RPGx_OnPluginReady()
	upgrade_id = RPGx_MakeUpgrade("BouncyBullets", 5, 15, 20);

public RPGx_OnPlayerHurt(victim, attacker, damage, weapon){
	new level = RPGx_GetUpgradeLevel(attacker, upgrade_id);
	if(level && weapon != CSW_KNIFE && weapon != CSW_HEGRENADE){
		new Float:velocity[3], Float:vorigin[3], Float:aorigin[3], Float:fv[3];
		
		entity_get_vector(victim, EV_VEC_origin, vorigin);
		entity_get_vector(attacker, EV_VEC_origin, aorigin);
		
		xs_vec_sub(vorigin, aorigin, fv);
		xs_vec_normalize(fv, velocity);
		
		velocity[0] *= float(level * 125);
		velocity[1] *= float(level * 125);
		velocity[2] *= float(level * 125);
		
		entity_set_vector(victim, EV_VEC_velocity, velocity);
		}
	}